<?php
include_once($_SERVER['DOCUMENT_ROOT']."/config.php");
include_once($gDOCUMENT_ROOT_SYSTEM.'include/filmAction.php');
include_once($gDOCUMENT_ROOT_SYSTEM.'include/filmDownloadAction.php');
include_once($gDOCUMENT_ROOT_SYSTEM.'templates/include/addon.php');
include_once($gDOCUMENT_ROOT_SYSTEM.'written_language/check_written_language.php');

include_once($gDOCUMENT_ROOT_SYSTEM.'/check_promulgator.php');
$filmAction = new filmAction();
$filmDownloadAction = new filmDownloadAction();

if(!isset($_POST['source_id'])||empty($_POST['source_id']))
{
	exit;
}
if(!isset($_POST['source_type'])||empty($_POST['source_type']))
{
	exit;
}

$douban_id = $_POST['douban_id'];
$where = array('douban_id'=>$douban_id);
$film_exist = $filmAction->isFilmExist($where,$column='id');
if($film_exist === false)
{
	exit;
}

$data = $_POST;
if(isset($_POST['spoken_language_id'])&&(count($_POST['spoken_language_id'])>0))
{
	$data['spoken_language_id_sum'] = array_sum($_POST['spoken_language_id']);
}
if(isset($_POST['written_language_id'])&&(count($_POST['written_language_id'])>0))
{
	$data['written_language_id_sum'] = array_sum($_POST['written_language_id']);
}
//$data['film_id'] = $film_id;

$result = $filmDownloadAction->AddFilmDownload($data);
if($result!==false)
{
	echo '已保存，<a href="'.addon::getMovieSubjectUrl($douban_id).'">返回</a>';
}
?>
